package com.klhappy.houyuan.activity;

import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.widget.TextView;

import com.google.gson.Gson;
import com.klhappy.houyuan.view.AbsActivity;
import com.klhappy.houyuan.R;
import com.klhappy.houyuan.bean.BaseJsonBean;
import com.klhappy.houyuan.bean.ResultBean;
import com.klhappy.houyuan.constant.UrlConstant;
import com.klhappy.houyuan.interfaces.CallBackInterModle;
import com.klhappy.houyuan.modle.JiaYuanModle;
import com.klhappy.houyuan.utils.JsonCode;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;

public class Stamp_RuleActivity extends AbsActivity implements CallBackInterModle {
	@InjectView(R.id.title)
	TextView title;
	@InjectView(R.id.right_text)
	TextView right_text;
	@InjectView(R.id.result)
	TextView result;

	@OnClick(R.id.click_ra)
	public void click_ra(){
		finish();
	}

	private JiaYuanModle modle;
	private ResultBean resultBean;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.food_stamp_rule);
		ButterKnife.inject(this);
		title.setText(R.string.food_stamp_rule);

		modle = new JiaYuanModle(this);
		modle.setCallBackInterModle(this);
		modle.getResult();
	}

	@Override
	public void CallBackFromModle(String url, BaseJsonBean o) {
		if (url.equals(UrlConstant.FOODRULE_URL)){
			if (o.getCode() == 200){
				Gson gson = new Gson();
				Log.e("this" ,"规则:" + gson.toJson(o));
				resultBean = JsonCode.getClass(o.getEntity() ,ResultBean.class);
				result.setText(Html.fromHtml(resultBean.getDesc()));
			}
		}
	}
}
